/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.just.dusin.ooii.database;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.just.dusin.ooii.util.DateUtil;

/**
 *
 * @author Administrator
 */
public class RealoutDao {

    private Connection conn = null;
    public int size;
    
            

    public RealoutDao(Connection conn) {
        this.conn = conn;
       
    }

    public boolean doCreate(String mineCode,int year,byte month,byte day) throws Exception{
        boolean flag = false;
        PreparedStatement pstmt = null;
        String sql = "INSERT INTO [realout]([orgcode],[year],[month],[day],[status])"
                + " VALUES (?,?,?,?,'0')";
        try {
            pstmt = this.conn.prepareStatement(sql);

            pstmt.setString(1, mineCode);
            pstmt.setInt(2, year);
            pstmt.setByte(3, month);
            pstmt.setByte(4,day);
            int len = pstmt.executeUpdate();
            if (len > 0) {
                flag = true;
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                pstmt.close();
            } catch (Exception e) {
                throw e;
            }
        }
        return flag;
    }

   

    //*更新产量，进行累加
//    public boolean doUpdateOut(DataOf5mBean d5m) throws Exception {
//        
//        boolean flag = false;
//        Calendar calendar = Calendar.getInstance();
//        
//        String orgCode = d5m.getMineCode();
//        int year = d5m.getYear();
//        int month = d5m.getMonth();
//        int day = d5m.getDay();
//        int hour = d5m.getHour();
//        int min = d5m.getMin();
//        
//        if(d5m.getMin()==0||d5m.getMin()==1){
//            calendar.set(d5m.getYear(), d5m.getMonth()-1, d5m.getDay(), d5m.getHour(), d5m.getMin());
//            calendar.add(Calendar.MINUTE, -2);
//            year = calendar.get(Calendar.YEAR);
//            month = calendar.get(Calendar.MONTH)+1;
//            day = calendar.get(Calendar.DATE);
//            hour = calendar.get(Calendar.HOUR_OF_DAY);
//        }
//        //需要改造，做减法时会出现负数
//        PreparedStatement pstmt = null;
//        String sql=null;
//        if(month==1&&day==1&&hour==0&&min==5){  //年 第一次数据
//            sql = "UPDATE [realout] SET [year]=?,[yearout]=?,[month]=?,[monthout]=?,[day]=?,[dayout]=?,[hour]=?,[hourout]=?,[class1out]=?,[class2out]=0,[class3out]=0,[min]=?,updatetime=? WHERE [orgcode]=?";
//        }else if(day==1&&hour==0&&min==5){  //月 第一次数据
//            sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=?,[day]=?,[dayout]=?,[hour]=?,[hourout]=?,[class1out]=?,[class2out]=0,[class3out]=0,[min]=?,updatetime=? WHERE [orgcode]=?";
//        }else if(hour==0&&min==5){  // 日 第一次 数据 0点班第一此数据
//            sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=?,[hour]=?,[hourout]=?,[class1out]=?,[class2out]=0,[class3out]=0,[min]=?,updatetime=? WHERE [orgcode]=?";
//           
//        }else if(min==5){  //小时 第一次数据
//            if(hour==0){ //0点班 第一次
//               sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class1out]=?,[class2out]=0,[class3out]=0,[min]=? ,updatetime=? WHERE [orgcode]=?"; 
//            }else if(hour==8){ //8d点班 第一次
//               sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class2out]=?,[class3out]=0,[min]=? ,updatetime=? WHERE [orgcode]=?"; 
//            }else if(hour==16){  //16点班 第一次
//               sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class3out]=?,[min]=? ,updatetime=?  WHERE [orgcode]=?";
//            }else { //其他小时 第一次
//                if(hour>=0&&hour<8){ //0点班 其他小时第一次
//                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class1out]=[class1out]+?,[min]=?,updatetime=? WHERE [orgcode]=?"; 
//                }else if(hour>=8&&hour<16){  //8点班 其他小时第一次
//                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class2out]=[class2out]+?,[min]=? ,updatetime=? WHERE [orgcode]=?";  
//                }else{ //16点班 其他小时第一次
//                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class3out]=[class3out]+?,[min]=?,updatetime=? WHERE [orgcode]=?"; 
//                }
//            }            
//           
//        }else { //其他 非小时 第一次数据数据
//                if(hour>=0&&hour<8){ //0点班 
//                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]-[hourout]+?,[month]=?,[monthout]=[monthout]-[hourout]+?,[day]=?,[dayout]=[dayout]-[hourout]+?,[hour]=?,[hourout]=?,[class1out]=[class1out]-[hourout]+?,[min]=?,updatetime=? WHERE [orgcode]=?";
//                }else if(hour>=8&&hour<16){  //8点班 
//                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]-[hourout]+?,[month]=?,[monthout]=[monthout]-[hourout]+?,[day]=?,[dayout]=[dayout]-[hourout]+?,[hour]=?,[hourout]=?,[class2out]=[class2out]-[hourout]+?,[min]=?,updatetime=? WHERE [orgcode]=?";
//                }else{ //16点班 
//                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]-[hourout]+?,[month]=?,[monthout]=[monthout]-[hourout]+?,[day]=?,[dayout]=[dayout]-[hourout]+?,[hour]=?,[hourout]=?,[class3out]=[class3out]-[hourout]+?,[min]=?,updatetime=? WHERE [orgcode]=?"; 
//                }               
//           
//        }           
//      
//        try {            
//            pstmt = this.conn.prepareStatement(sql);
//            pstmt.setInt(1,d5m.getYear());
//            pstmt.setDouble(2, d5m.getSumof5min());
//            pstmt.setInt(3,d5m.getMonth());
//            pstmt.setDouble(4, d5m.getSumof5min());
//            pstmt.setInt(5, d5m.getDay());
//            pstmt.setDouble(6, d5m.getSumof5min());
//            pstmt.setInt(7,d5m.getHour());
//            pstmt.setDouble(8, d5m.getSumof5min());
//            pstmt.setDouble(9, d5m.getSumof5min());
//            pstmt.setByte(10, d5m.getMin());
//            pstmt.setTimestamp(11, new java.sql.Timestamp(new Date().getTime()));
//            pstmt.setString(12, d5m.getMineCode());
//            
//            int len = pstmt.executeUpdate();
//            if (len > 0) {
//                flag = true;
//            }
//        } catch (Exception e) {
//            throw e;
//        } finally {
//            try {
//                pstmt.close();
//            } catch (Exception e) {
//                throw e;
//            }
//        }
//        return flag;
//    }

    /**
     * 实时产量更新，5分钟一更新。检查连续5分钟。补上中间缺少数据，产量为0；
     * @param d5m
     * @return
     * @throws Exception 
     */
    public boolean doUpdateOut(DataOf5mBean d5m) throws Exception {
        boolean flag = false;
        String orgCode = d5m.getMineCode();
        Date previousTime = this.getCurrentTime(orgCode);
        Calendar prevCalendar = Calendar.getInstance();
        prevCalendar.setTime(previousTime);        
        Calendar currentCalendar = Calendar.getInstance();        
        currentCalendar.set(d5m.getYear(), d5m.getMonth()-1, d5m.getDay(), d5m.getHour(), d5m.getMin(),0);
        
        DataOf5mBean nullD5m = new DataOf5mBean();//0产量        
        nullD5m.setMineCode(d5m.getMineCode());
        nullD5m.setCityName(d5m.getCityName());
        nullD5m.setCountyName(d5m.getCountyName());
        nullD5m.setMineName(d5m.getMineName());
        nullD5m.setRate(d5m.getRate());
        nullD5m.setStatus(d5m.getStatus());
        nullD5m.setSumof5min(0);
        
        if(prevCalendar.after(currentCalendar))      //当前为过时数据，抛弃
            return false;
        
        prevCalendar.add(Calendar.MINUTE, 6);        
        if(prevCalendar.get(Calendar.YEAR)<currentCalendar.get(Calendar.YEAR)){  //如果缺新年第一次数据，则补上第一次数据
            nullD5m.setYear(d5m.getYear());
            nullD5m.setMonth((byte)1);
            nullD5m.setDay((byte)1);
            nullD5m.setHour((byte)0);
            nullD5m.setMin((byte)0);
            this.updateOut(nullD5m);
        }else  if(prevCalendar.get(Calendar.MONTH)+1<d5m.getMonth()){   //数据跨月
            nullD5m.setYear(d5m.getYear());
            nullD5m.setMonth(d5m.getMonth());
            nullD5m.setDay((byte)1);
            nullD5m.setHour((byte)0);
            nullD5m.setMin((byte)0);
            this.updateOut(nullD5m);
        }else  if(prevCalendar.get(Calendar.DATE)<d5m.getDay()){   //数据跨日
            nullD5m.setYear(d5m.getYear());
            nullD5m.setMonth(d5m.getMonth());
            nullD5m.setDay(d5m.getDay());
            nullD5m.setHour((byte)0);
            nullD5m.setMin((byte)0);
            this.updateOut(nullD5m);
        }else if(prevCalendar.get(Calendar.HOUR_OF_DAY)<d5m.getHour()){   //数据跨小时            
            nullD5m.setYear(d5m.getYear());
            nullD5m.setMonth(d5m.getMonth());
            nullD5m.setDay(d5m.getDay());
            nullD5m.setHour(d5m.getHour());
            nullD5m.setMin((byte)0);
            this.updateOut(nullD5m);
        }
        
        /*while(prevCalendar.before(currentCalendar)){
            nullD5m.setYear((short)prevCalendar.get(Calendar.YEAR));
            nullD5m.setMonth((byte)(Calendar.MONTH+1));
            nullD5m.setDay((byte)(Calendar.DATE));
            nullD5m.setHour((byte)Calendar.HOUR_OF_DAY);
            nullD5m.setMin((byte)Calendar.MINUTE);
            this.updateOut(nullD5m);            
        }*/            
        updateOut(d5m);        
        return flag;        
    }
    
    //*更新产量，进行累加
    private boolean updateOut(DataOf5mBean d5m) throws Exception {
        
        boolean flag = false;

        int year = d5m.getYear();
        int month = d5m.getMonth();
        int day = d5m.getDay();
        int hour = d5m.getHour();
        int min = d5m.getMin();        
        
        
        PreparedStatement pstmt = null;
        String sql=null;
        if(month==1&&day==1&&hour==0&&min==0){  //年 第一次数据
            sql = "UPDATE [realout] SET [year]=?,[yearout]=?,[month]=?,[monthout]=?,[day]=?,[dayout]=?,[hour]=?,[hourout]=?,[class1out]=?,[class2out]=0,[class3out]=0,[min]=?,updatetime=? WHERE [orgcode]=?";
        }else if(day==1&&hour==0&&min==0){  //月 第一次数据
            sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=?,[day]=?,[dayout]=?,[hour]=?,[hourout]=?,[class1out]=?,[class2out]=0,[class3out]=0,[min]=?,updatetime=? WHERE [orgcode]=?";
        }else if(hour==0&&min==0){  // 日 第一次 数据 0点班第一此数据
            sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=?,[hour]=?,[hourout]=?,[class1out]=?,[class2out]=0,[class3out]=0,[min]=?,updatetime=? WHERE [orgcode]=?";
           
        }else if(min==0){  //小时 第一次数据
            if(hour==0){ //0点班 第一次
               sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class1out]=?,[class2out]=0,[class3out]=0,[min]=? ,updatetime=? WHERE [orgcode]=?"; 
            }else if(hour==8){ //8d点班 第一次
               sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class2out]=?,[class3out]=0,[min]=? ,updatetime=? WHERE [orgcode]=?"; 
            }else if(hour==16){  //16点班 第一次
               sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class3out]=?,[min]=? ,updatetime=?  WHERE [orgcode]=?";
            }else { //其他小时 第一次
                if(hour>=0&&hour<8){ //0点班 其他小时第一次
                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class1out]=[class1out]+?,[min]=?,updatetime=? WHERE [orgcode]=?"; 
                }else if(hour>=8&&hour<16){  //8点班 其他小时第一次
                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class2out]=[class2out]+?,[min]=? ,updatetime=? WHERE [orgcode]=?";  
                }else{ //16点班 其他小时第一次
                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=?,[class3out]=[class3out]+?,[min]=?,updatetime=? WHERE [orgcode]=?"; 
                }
            }            
           
        }else { //其他 非小时 第一次数据数据
                if(hour>=0&&hour<8){ //0点班 
                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=[hourout]+?,[class1out]=[class1out]+?,[min]=?,updatetime=? WHERE [orgcode]=?";
                }else if(hour>=8&&hour<16){  //8点班 
                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=[hourout]+?,[class2out]=[class2out]+?,[min]=?,updatetime=? WHERE [orgcode]=?";
                }else{ //16点班 
                    sql = "UPDATE [realout] SET [year]=?,[yearout]=[yearout]+?,[month]=?,[monthout]=[monthout]+?,[day]=?,[dayout]=[dayout]+?,[hour]=?,[hourout]=[hourout]+?,[class3out]=[class3out]+?,[min]=?,updatetime=? WHERE [orgcode]=?"; 
                }               
           
        }           
      
        try {            
            pstmt = this.conn.prepareStatement(sql);
            pstmt.setInt(1,d5m.getYear());
            pstmt.setDouble(2, d5m.getSumof5min());
            pstmt.setInt(3,d5m.getMonth());
            pstmt.setDouble(4, d5m.getSumof5min());
            pstmt.setInt(5, d5m.getDay());
            pstmt.setDouble(6, d5m.getSumof5min());
            pstmt.setInt(7,d5m.getHour());
            pstmt.setDouble(8, d5m.getSumof5min());
            pstmt.setDouble(9, d5m.getSumof5min());
            pstmt.setByte(10, d5m.getMin());
            pstmt.setTimestamp(11, new java.sql.Timestamp(new Date().getTime()));
            pstmt.setString(12, d5m.getMineCode());
            
            int len = pstmt.executeUpdate();
            if (len > 0) {
                flag = true;
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                pstmt.close();
            } catch (Exception e) {
                throw e;
            }
        }
        return flag;
    }
    
     public boolean doUpdateStatus(String status,String mineCode) throws Exception {
        boolean flag = false;
        PreparedStatement pstmt = null;
        String sql=null;
        sql = "UPDATE [realout] SET [status]=? WHERE [orgcode]=?";
           
        try {
            
            pstmt = this.conn.prepareStatement(sql);
            pstmt.setString(1,status );
            pstmt.setString(2, mineCode);
            
            int len = pstmt.executeUpdate();
            if (len > 0) {
                flag = true;
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                pstmt.close();
            } catch (Exception e) {
                throw e;
            }
        }
        return flag;
    }
     
     //获取最新更新时间
     public Date getCurrentTime(String orgCode) throws Exception{
        Date rtDate=null;
        PreparedStatement pstmt = null;
        String sql = "select year,month,day,hour,min from  realout WHERE orgCode=? ";
        try {
            pstmt = this.conn.prepareStatement(sql);
            pstmt.setString (1,orgCode);            
            ResultSet rs = pstmt.executeQuery();
            if(rs.next()){
                
                int year= rs.getInt(1);
                int month = rs.getInt(2);
                int day = rs.getInt(3);
                int hour = rs.getInt(4);
                int min = rs.getInt(5);
                
                rtDate = DateUtil.get(year, month, day, hour, min, 0);
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                pstmt.close();
            } catch (Exception e) {
                throw e;
            }
        }
        return rtDate;
    } 
     
     
    public boolean doDelete(long pid) throws Exception {
        boolean flag = false;
        PreparedStatement pstmt = null;
        String sql = "DELETE FROM hourout WHERE id=?";
        try {
            pstmt = this.conn.prepareStatement(sql);
            pstmt.setLong(1, pid);
            int len = pstmt.executeUpdate();
            if (len > 0) {
                flag = true;
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                pstmt.close();
            } catch (Exception e) {
                throw e;
            }
        }
        return flag;
    }

    public boolean doDelete(String[] pids) throws Exception {
        for (String pid : pids) {
            long id = Long.parseLong(pid);
            doDelete(id);
        }
        return true;
    }
    
    public List<RealoutBean> findAll(int beginIndex, int size,String orgCode) throws Exception {
		List<RealoutBean> all = new ArrayList<RealoutBean>();
		PreparedStatement pstmt = null;
		PreparedStatement pstmtsize = null;
		String sqlsize = "select count(*) from realout where orgcode like '"+orgCode+"%'";

		String sql =  "select [orgcode],[smallname],[yearplan],[monthplan],[dayplan],[hourplan],[yearout],[monthout],[dayout],[hourout],[class1out],[class2out] ,[class3out],"+
		                      "[status] ,[year],[month],[day],[hour],[min]  from "+
                                      "(select realout.[id],realout.[orgcode],[smallname],[yearplan],[monthplan],[dayplan],[hourplan],[yearout],[monthout],[dayout],[hourout],[class1out],[class2out] ,[class3out],"+
		                          "realout.[status] ,realout.[year],[month],[day],[hour],[min] ,row_number() over(order by realout.id) rn "+
	                                  "from realout  left join org  on realout.orgcode=org.orgcode left join yearplan on realout.orgcode= yearplan.orgcode and realout.year = yearplan.year where realout.orgcode like '"+orgCode+"%' ) t where t.rn>=? and t.rn<?";
		try {
			pstmtsize = this.conn.prepareStatement(sqlsize);
			ResultSet rssize = pstmtsize.executeQuery(); //
			rssize.next();
			this.size = rssize.getInt(1);

			pstmt = this.conn.prepareStatement(sql);			
			pstmt.setInt(1, beginIndex+1);
			pstmt.setInt(2, beginIndex + size+1);
			ResultSet rs = pstmt.executeQuery(); //
			RealoutBean realout = null;
			while (rs.next()) { //
				realout = new RealoutBean();
				realout.setOrgCode(rs.getString(1));
                                realout.setSmallName(rs.getString(2));
                                double yearPlan = rs.getDouble(3);
                                realout.setYearPlan(yearPlan/1000);
                                realout.setMonthPlan(rs.getDouble(4)/1000);
                                realout.setDayPlan(rs.getDouble(5));
                                realout.setHourPlan(rs.getDouble(6));
                                double yearOut=rs.getDouble(7);
                                realout.setYearOut(yearOut/1000);
                                realout.setMonthOut(rs.getDouble(8)/1000);
                                realout.setDayOut(rs.getDouble(9));
                                realout.setHourOut(rs.getDouble(10));
                                realout.setClass1Out(rs.getDouble(11));
                                realout.setClass2Out(rs.getDouble(12));
                                realout.setClass3Out(rs.getDouble(13));
                                realout.setStatus(rs.getString(14));
                                
                                realout.setYearOverFill(Math.max(yearOut-yearPlan, 0)/1000);
                                realout.setYearOverFillRate(yearOut/yearPlan*100);
                                StringBuilder sb = new StringBuilder();
                                short year = rs.getShort(15);
                                byte month = rs.getByte(16);
                                byte day = rs.getByte(17);
                                byte hour = rs.getByte(18);
                                byte min = rs.getByte(19);
                                DecimalFormat df = new DecimalFormat("00");
                                sb.append(year).append("-").append(df.format(month)).append("-").append(df.format(day)).append(" ").append(df.format(hour)).append(":").append(df.format(min));
                                realout.setTime(sb.toString());
				all.add(realout); 
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			try {
				pstmt.close();
			} catch (Exception e) {
				throw e;
			}
		}
		return all;
	}
    
    public List<RealoutBean> findAll() throws Exception {
		List<RealoutBean> all = new ArrayList<RealoutBean>();
		PreparedStatement pstmt = null;
		

		String sql =  "select [orgcode],[status] ,[year],[month],[day],[hour],[min] ,[updatetime] from realout ";
                                     
		try {
		
			pstmt = this.conn.prepareStatement(sql);
			ResultSet rs = pstmt.executeQuery(); //
			RealoutBean realout = null;
			while (rs.next()) { //
				realout = new RealoutBean();
				realout.setOrgCode(rs.getString(1));                           
                                realout.setStatus(rs.getString(2));                              
                                StringBuilder sb = new StringBuilder();
                                short year = rs.getShort(3);
                                byte month = rs.getByte(4);
                                byte day = rs.getByte(5);
                                byte hour = rs.getByte(6);
                                byte min = rs.getByte(7);
                                DecimalFormat df = new DecimalFormat("00");
                                sb.append(year).append("-").append(df.format(month)).append("-").append(df.format(day)).append(" ").append(df.format(hour)).append(":").append(df.format(min));                                
                                realout.setTime(sb.toString());                                
                                Date updatetime = rs.getTimestamp(8);           
                                
                                realout.setUpdateTime(DateUtil.get(updatetime, "yyyy-MM-dd HH:mm"));
				all.add(realout); 
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			try {
				pstmt.close();
			} catch (Exception e) {
				throw e;
			}
		}
		return all;
	}

    public int getTotalSize() {
        return size;
    }
}
